<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('配偶成员列表')" />
</head>
<body class="gray-bg">
     <div class="container-div">
        <div class="row">
            <div class="col-sm-12 search-collapse">
                <form id="formId">
                    <div class="select-list">
                        <ul>
                            <li>
                                <label>编号：</label>
                                <input type="text" name="mId"/>
                            </li>
                            <li>
                                <label>姓氏：</label>
                                <input type="text" name="surname"/>
                            </li>
                            <li>
                                <label>名字：</label>
                                <input type="text" name="name"/>
                            </li>
                            <li>
                                <label>家族：</label>
                                <select name="surnameId">
                                    <option value="0">所有</option>
                                    <option th:each="dict : ${fcanList}" th:text="${dict.name}" th:value="${dict.cId}"></option>
                                </select>
                            </li>
                            <li>
                                <label>登记状态：</label>
                                <select name="statusFlag" th:with="type=${@dict.getType('f_status_flag')}">
                                    <option value="">所有</option>
                                    <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                                </select>
                            </li>
                            <li>
                                <label>健在状态：</label>
                                <select name="deathFlag">
                                    <option value="">所有</option>
                                    <option value="0">健在</option>
                                    <option value="1">死亡</option>
                                </select>
                            </li>
                            <li>
                                <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                                <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                            </li>
                        </ul>
                    </div>
                </form>
            </div>

            <div class="btn-group-sm" id="toolbar" role="group">
                <a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="family:mate:add">
                    <i class="fa fa-plus"></i> 添加
                </a>
                <a class="btn btn-primary single disabled" onclick="$.operate.edit()" shiro:hasPermission="family:mate:edit">
                    <i class="fa fa-edit"></i> 修改
                </a>
                <a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()" shiro:hasPermission="family:mate:remove">
                    <i class="fa fa-remove"></i> 删除
                </a>
                <a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="family:mate:export" style="display: none;">
                    <i class="fa fa-download"></i> 导出
                </a>
            </div>
            <div class="col-sm-12 select-table table-striped">
                <table id="bootstrap-table"></table>
            </div>
        </div>
    </div>
    <th:block th:include="include :: footer" />
    <script th:inline="javascript">
        var editFlag = [[${@permission.hasPermi('family:mate:edit')}]];
        var removeFlag = [[${@permission.hasPermi('family:mate:remove')}]];
        var prefix = ctx + "family/mate";

        /*家族配偶管理-编辑头像*/
        function avatar(mid) {
            var url = prefix + '/avatar/' + mid;
            top.layer.open({
                type: 2,
                area: [$(window).width() + 'px', $(window).height() + 'px'],
                fix: false,
                //不固定
                maxmin: true,
                shade: 0.3,
                title: "修改头像",
                content: url,
                btn: ['确定', '关闭'],
                // 弹层外区域关闭
                shadeClose: true,
                yes: function(index, layero) {
                    var iframeWin = layero.find('iframe')[0];
                    iframeWin.contentWindow.submitHandler(index, layero);
                },
                cancel: function(index) {
                    return true;
                }
            });
        }

        $(function() {
            var options = {
                url: prefix + "/list",
                createUrl: prefix + "/add",
                updateUrl: prefix + "/edit/{id}",
                removeUrl: prefix + "/remove",
                exportUrl: prefix + "/export",
                modalName: "配偶成员",
                columns: [{
                    checkbox: true
                },
                {
                    field: 'mId',
                    title: '编号',
                    align: 'center',
                    visible: true
                },
                {
                    field: 'surname',
                    title: '姓氏',
                    align: 'center'
                },
                {
                    field: 'name',
                    title: '名字',
                    align: 'center'
                },
                {
                    field: 'birthdayStr',
                    title: '出生日期',
                    align: 'center',
                },
                {
                    field: 'fatherName',
                    title: '父亲姓名',
                    align: 'center'
                },
                {
                    field: 'memberNames',
                    title: '配偶姓名',
                    align: 'center'
                },
                {
                    field: 'surnameName',
                    title: '所属家族',
                    align: 'center'
                },
                {
                    field: 'headUrl',
                    title: '头像',
                    align: 'center',
                    formatter:function (value, row, index){
                        var headUrl = value;
                        if(headUrl == undefined || headUrl == "")
                        {
                            headUrl = "/img/profile.jpg";
                        }
                        //return '<img class="img-circle img-lg" src="' + headUrl + '" style="width: 80px;height: 80px;" onerror="this.src=\'/img/profile.jpg\'">'
                        return $.table.imageView(headUrl);
                    }
                },
                {
                    field: 'statusFlag',
                    title: '谱书登记状态',
                    align: 'center',
                    formatter:function (value, row, index){
                        switch (value){
                            case "0":
                                return "未登记";
                            case "1":
                                return "已登记";
                        }
                    }
                },
                {
                    field: 'deathFlag',
                    title: '是否健在',
                    align: 'center',
                    formatter:function (value, row, index){
                        switch (value){
                            case "0":
                                return "是";
                            case "1":
                                return "否";
                        }
                    }
                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function(value, row, index) {
                        var actions = [];
                        actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.mId + '\')"><i class="fa fa-edit"></i>编辑</a> ');
                        actions.push('<a class="btn btn-success btn-xs href="javascript:void(0)" onclick="avatar(\'' + row.mId + '\')"><i class="fa fa-edit"></i>编辑头像</a> ');
                        actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.mId + '\')"><i class="fa fa-remove"></i>删除</a>');
                        return actions.join('');
                    }
                }]
            };
            $.table.init(options);
        });
    </script>
</body>
</html>